import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mvvm_provider/page/home/data/model/cartoon_model.dart';
import 'package:mvvm_provider/widgets/app_net_image.dart';

class CollectionItem extends StatelessWidget {
  final CartoonModel model;
  const CollectionItem({super.key, required this.model});

  /// 文字展示
  Widget _textWidget() {
    return Expanded(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            model.title ?? '',
            maxLines: 2,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(
              color: Colors.black,
              fontWeight: FontWeight.w500,
              fontSize: 15.sp,
            ),
          ),
          SizedBox(height: 6.h),
          Text(
            model.createTime ?? '',
            maxLines: 2,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(color: Colors.black45, fontWeight: FontWeight.w500, fontSize: 14.sp),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 6.h),
      margin: EdgeInsets.only(bottom: 1.h),
      width: 1.sw,
      color: Colors.white,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          AppNetImage(
            imageUrl: model.image ?? '',
            width: 120.w,
            height: 80.w,
            fit: BoxFit.cover,
            radius: 8.h,
          ),
          SizedBox(
            width: 10.w,
          ),
          _textWidget(),
        ],
      ),
    );
  }
}
